package com.entity;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by Administrator on 2015/7/22.
 */
@Entity
public class User {
    private int userId;
    private String userName;
    private String userPassword;
    private String userTelephone;
    private String userUsername;
    private Integer userIsadmin;
    private Set<House> houses;

    public User() {
    }

    public User(int userId, String userName, String userPassword) {
        this.userId = userId;
        this.userName = userName;
        this.userPassword = userPassword;
    }

    @Id
    @Column(name = "user_id")
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "user__name")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Basic
    @Column(name = "user_password")
    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    @Basic
    @Column(name = "user__telephone")
    public String getUserTelephone() {
        return userTelephone;
    }

    public void setUserTelephone(String userTelephone) {
        this.userTelephone = userTelephone;
    }

    @Basic
    @Column(name = "user_username")
    public String getUserUsername() {
        return userUsername;
    }

    public void setUserUsername(String userUsername) {
        this.userUsername = userUsername;
    }

    @Basic
    @Column(name = "user_isadmin")
    public Integer getUserIsadmin() {
        return userIsadmin;
    }

    public void setUserIsadmin(Integer userIsadmin) {
        this.userIsadmin = userIsadmin;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (userId != user.userId) return false;
        if (userName != null ? !userName.equals(user.userName) : user.userName != null) return false;
        if (userPassword != null ? !userPassword.equals(user.userPassword) : user.userPassword != null) return false;
        if (userTelephone != null ? !userTelephone.equals(user.userTelephone) : user.userTelephone != null)
            return false;
        if (userUsername != null ? !userUsername.equals(user.userUsername) : user.userUsername != null) return false;
        if (userIsadmin != null ? !userIsadmin.equals(user.userIsadmin) : user.userIsadmin != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = userId;
        result = 31 * result + (userName != null ? userName.hashCode() : 0);
        result = 31 * result + (userPassword != null ? userPassword.hashCode() : 0);
        result = 31 * result + (userTelephone != null ? userTelephone.hashCode() : 0);
        result = 31 * result + (userUsername != null ? userUsername.hashCode() : 0);
        result = 31 * result + (userIsadmin != null ? userIsadmin.hashCode() : 0);
        return result;
    }

    @OneToMany(mappedBy = "user")
    public Set<House> getHouses() {
        return houses;
    }

    public void setHouses(Set<House> houses) {
        this.houses = houses;
    }
}
